var t = getApp();

Component({
    properties: {
        debtId: {
            type: null
        }
    },
    data: {
        inputs: "",
        good_page: 1,
        order_field: "",
        order_by: "",
        is_hot: 0,
        cid: "",
        debtId: ""
    },
    lifetimes: {
        attached: function() {
            this.getGoodsData(), console.log("attached");
        },
        moved: function() {
            console.log("moved");
        },
        detached: function() {
            console.log("detached");
        }
    },
    methods: {
        goToDetail: function(t) {
            var a = t.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + a + "&debtId=" + this.data.debtId
            });
        },
        toggle: function(t) {
            var a = "";
            switch (t.currentTarget.dataset.idx) {
              case 2:
                this.setData({
                    hascolor: 2
                }), "2_2" == this.data.colorshow ? (this.setData({
                    colorshow: "2_1"
                }), a = "show_sales", this.setData({
                    order_field: a,
                    order_by: "asc"
                })) : (this.setData({
                    colorshow: "2_2"
                }), a = "show_sales", this.setData({
                    order_field: a,
                    order_by: "desc"
                }));
                break;

              case 3:
                this.setData({
                    hascolor: 3
                }), "3_2" == this.data.colorshow ? (this.setData({
                    colorshow: "3_1"
                }), a = "price", this.setData({
                    order_field: a,
                    order_by: "asc"
                })) : (this.setData({
                    colorshow: "3_2"
                }), a = "price", this.setData({
                    order_field: a,
                    order_by: "desc"
                }));
                break;

              case 5:
                this.setData({
                    hascolor: 5
                }), "5_2" == this.data.colorshow ? (this.setData({
                    colorshow: "5_1"
                }), a = "id", this.setData({
                    order_field: a,
                    order_by: "asc"
                })) : (this.setData({
                    colorshow: "5_2"
                }), a = "id", this.setData({
                    order_field: a,
                    order_by: "desc"
                }));
            }
            this.getGoodsData();
        },
        getGoodsData: function() {
            var a = this, e = t.getNetAddresss("goods.goods.search-goods"), o = {
                page: this.data.good_page,
                order_field: this.data.order_field,
                order_by: this.data.order_by,
                "search[plugin_id]": [ -1, 44, 92 ]
            };
            t._postNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var e = t.data;
                    1 == e.result && (a.setData({
                        goodsArr: e.data.data,
                        good_total_page: e.data.last_page,
                        current_page: e.data.current_page
                    }), a.triggerEvent("getSort", {
                        good_total_page: a.data.good_total_page,
                        current_page: a.data.current_page
                    }));
                },
                fail: function(t) {
                    console.log(t.msg);
                }
            });
        },
        nexTgetGoodsData: function() {
            var a = this, e = t.getNetAddresss("goods.goods.search-goods"), o = {
                page: this.data.good_page,
                order_field: this.data.order_field,
                order_by: this.data.order_by,
                "search[plugin_id]": [ -1, 44, 92 ]
            };
            t._postNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var e = t.data;
                    1 == e.result && (a.setData({
                        goodsArr: a.data.goodsArr.concat(e.data.data),
                        good_total_page: e.data.last_page,
                        current_page: e.data.current_page
                    }), a.triggerEvent("getSort", {
                        good_total_page: a.data.good_total_page,
                        current_page: a.data.current_page
                    }));
                },
                fail: function(t) {
                    wx.showToast({
                        title: t.msg
                    });
                }
            });
        }
    }
});